var app = new Vue({
	el: '#app',
	data: {
		file:'',
		message: 'Hello Vue!',
		ActiveImgList: [{
			url: './img/img_1.png'
		}, {
			url: './img/img_2.png'
		}, {
			url: './img/img_3.png'
		}, {
			url: './img/img_4.png'
		}, {
			url: './img/img_5.png'
		}, {
			url: './img/img_6.png'
		}, {
			url: './img/img_7.png'
		}, {
			url: './img/img_8.png'
		}, ],
		isActiveImg: 0,
		formData: {
			name: '逍遥', //姓名
			address: '', //地址
			orider: '',
			ipone: '',
			card_t1: '',
			card_t2: '',
			email: '',
			common: "",
			img_num: '1',

			file_num: '15',
			files: ''
		},
		// 文件列表
		filesList:[
			// {name:'12312'}
		],
		formValidate: [{
			name: ''
		}]
	},
	methods: {
		//     requireImg(url){
		//       console.log(url)
		// return require(`.${url}`)
		//     }
		vilidateForm() {
			let text = '';
			if (!this.formData.name) {
				return {
					status: false,
					text: '收货人不能为空',
					name: 'formData_name'
				}
			}
			if (!this.formData.ipone) {
				return {
					status: false,
					text: '收货人联系方式不能为空',
					name: 'formData_ipone'
				}
			}

			// if (!this.formData.address) {
			// 	return {
			// 		status: false,
			// 		text: '收货地址不能为空'
			// 	}
			// }
			if (!this.formData.email) {
				return {
					status: false,
					text: '邮箱不能为空',
					name: 'formData_email'
				}
			}
			let phoneReg = /^[1][3,4,5,6,7,8,9][0-9]{9}$/;
			if (!phoneReg.test(this.formData.ipone)) {
				return {
					status: false,
					text: '收货人联系方式格式有误',
					name: 'formData_ipone'
				}
			}


			return {
				status: true,
			}
		},
		submitForm() {
			let validate = this.vilidateForm()
			if (!validate.status) {
				console.log(validate)

				return alert(validate.text);
			}
			console.log('表单验证通过')
		},
		selectImg(ev){
			console.log(ev)
			let file=ev.target.files[0]
			this.filesList[this.filesList.length]={name:file.name,file:file};
			console.log(this.filesList)
			this.file='';
			
		},
		colseImg(index){
		let list=[...this.filesList]
		list[index]=null;
		console.log(list)
		
		console.log(list.filter(res=>{
			return res?true:false
		}))
		this.filesList=list.filter(res=>{
			return res!==null
		})
		console.log(this.filesList)
		}
	}
})
